package com.authine.cloudpivot.ext.listener;

import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @author luoyj
 * @date 2021/2/25.
 * @description
 */
@Slf4j
@Component
@RequiredArgsConstructor
@EnableBinding(AppMQBinding.class)
public class AppMQConsumer {

    private final AppMQBinding appMQBinding;

    @StreamListener(AppMQBinding.APP_INFO)
    private void consumerAppMQ(Message<String> message) {
        String payload = message.getPayload();
        log.info("自定义服务 AppMQConsumer 【MQ接收内容】：{}", payload);
        AppDeploymentDto appDeploymentDto = JSONObject.parseObject(payload, AppDeploymentDto.class);
    }
}
